// **********************************************************************
//
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

// Ice version 3.3.1
// Generated from file `Laser.ice'

#include <Laser.h>
#include <Ice/LocalException.h>
#include <Ice/ObjectFactory.h>
#include <Ice/BasicStream.h>
#include <IceUtil/Iterator.h>
#include <IceUtil/ScopedArray.h>

#ifndef ICE_IGNORE_VERSION
#   if ICE_INT_VERSION / 100 != 303
#       error Ice version mismatch!
#   endif
#   if ICE_INT_VERSION % 100 > 50
#       error Beta header file detected
#   endif
#   if ICE_INT_VERSION % 100 < 1
#       error Ice patch level mismatch!
#   endif
#endif

static const ::std::string __RoboCompLaser__Laser__getLaserData_name = "getLaserData";

static const ::std::string __RoboCompLaser__Laser__getLaserConfData_name = "getLaserConfData";

::Ice::Object* IceInternal::upCast(::RoboCompLaser::Laser* p) { return p; }
::IceProxy::Ice::Object* IceInternal::upCast(::IceProxy::RoboCompLaser::Laser* p) { return p; }

void
RoboCompLaser::__read(::IceInternal::BasicStream* __is, ::RoboCompLaser::LaserPrx& v)
{
    ::Ice::ObjectPrx proxy;
    __is->read(proxy);
    if(!proxy)
    {
        v = 0;
    }
    else
    {
        v = new ::IceProxy::RoboCompLaser::Laser;
        v->__copyFrom(proxy);
    }
}

bool
RoboCompLaser::LaserConfData::operator==(const LaserConfData& __rhs) const
{
    if(this == &__rhs)
    {
        return true;
    }
    if(driver != __rhs.driver)
    {
        return false;
    }
    if(device != __rhs.device)
    {
        return false;
    }
    if(staticConf != __rhs.staticConf)
    {
        return false;
    }
    if(maxMeasures != __rhs.maxMeasures)
    {
        return false;
    }
    if(maxDegrees != __rhs.maxDegrees)
    {
        return false;
    }
    if(maxRange != __rhs.maxRange)
    {
        return false;
    }
    if(minRange != __rhs.minRange)
    {
        return false;
    }
    if(iniRange != __rhs.iniRange)
    {
        return false;
    }
    if(endRange != __rhs.endRange)
    {
        return false;
    }
    if(cluster != __rhs.cluster)
    {
        return false;
    }
    if(sampleRate != __rhs.sampleRate)
    {
        return false;
    }
    if(angleRes != __rhs.angleRes)
    {
        return false;
    }
    if(angleIni != __rhs.angleIni)
    {
        return false;
    }
    return true;
}

bool
RoboCompLaser::LaserConfData::operator<(const LaserConfData& __rhs) const
{
    if(this == &__rhs)
    {
        return false;
    }
    if(driver < __rhs.driver)
    {
        return true;
    }
    else if(__rhs.driver < driver)
    {
        return false;
    }
    if(device < __rhs.device)
    {
        return true;
    }
    else if(__rhs.device < device)
    {
        return false;
    }
    if(staticConf < __rhs.staticConf)
    {
        return true;
    }
    else if(__rhs.staticConf < staticConf)
    {
        return false;
    }
    if(maxMeasures < __rhs.maxMeasures)
    {
        return true;
    }
    else if(__rhs.maxMeasures < maxMeasures)
    {
        return false;
    }
    if(maxDegrees < __rhs.maxDegrees)
    {
        return true;
    }
    else if(__rhs.maxDegrees < maxDegrees)
    {
        return false;
    }
    if(maxRange < __rhs.maxRange)
    {
        return true;
    }
    else if(__rhs.maxRange < maxRange)
    {
        return false;
    }
    if(minRange < __rhs.minRange)
    {
        return true;
    }
    else if(__rhs.minRange < minRange)
    {
        return false;
    }
    if(iniRange < __rhs.iniRange)
    {
        return true;
    }
    else if(__rhs.iniRange < iniRange)
    {
        return false;
    }
    if(endRange < __rhs.endRange)
    {
        return true;
    }
    else if(__rhs.endRange < endRange)
    {
        return false;
    }
    if(cluster < __rhs.cluster)
    {
        return true;
    }
    else if(__rhs.cluster < cluster)
    {
        return false;
    }
    if(sampleRate < __rhs.sampleRate)
    {
        return true;
    }
    else if(__rhs.sampleRate < sampleRate)
    {
        return false;
    }
    if(angleRes < __rhs.angleRes)
    {
        return true;
    }
    else if(__rhs.angleRes < angleRes)
    {
        return false;
    }
    if(angleIni < __rhs.angleIni)
    {
        return true;
    }
    else if(__rhs.angleIni < angleIni)
    {
        return false;
    }
    return false;
}

void
RoboCompLaser::LaserConfData::__write(::IceInternal::BasicStream* __os) const
{
    __os->write(driver);
    __os->write(device);
    __os->write(staticConf);
    __os->write(maxMeasures);
    __os->write(maxDegrees);
    __os->write(maxRange);
    __os->write(minRange);
    __os->write(iniRange);
    __os->write(endRange);
    __os->write(cluster);
    __os->write(sampleRate);
    __os->write(angleRes);
    __os->write(angleIni);
}

void
RoboCompLaser::LaserConfData::__read(::IceInternal::BasicStream* __is)
{
    __is->read(driver);
    __is->read(device);
    __is->read(staticConf);
    __is->read(maxMeasures);
    __is->read(maxDegrees);
    __is->read(maxRange);
    __is->read(minRange);
    __is->read(iniRange);
    __is->read(endRange);
    __is->read(cluster);
    __is->read(sampleRate);
    __is->read(angleRes);
    __is->read(angleIni);
}

bool
RoboCompLaser::TData::operator==(const TData& __rhs) const
{
    if(this == &__rhs)
    {
        return true;
    }
    if(dist != __rhs.dist)
    {
        return false;
    }
    if(angle != __rhs.angle)
    {
        return false;
    }
    return true;
}

bool
RoboCompLaser::TData::operator<(const TData& __rhs) const
{
    if(this == &__rhs)
    {
        return false;
    }
    if(dist < __rhs.dist)
    {
        return true;
    }
    else if(__rhs.dist < dist)
    {
        return false;
    }
    if(angle < __rhs.angle)
    {
        return true;
    }
    else if(__rhs.angle < angle)
    {
        return false;
    }
    return false;
}

void
RoboCompLaser::TData::__write(::IceInternal::BasicStream* __os) const
{
    __os->write(dist);
    __os->write(angle);
}

void
RoboCompLaser::TData::__read(::IceInternal::BasicStream* __is)
{
    __is->read(dist);
    __is->read(angle);
}

void
RoboCompLaser::__writeTLaserData(::IceInternal::BasicStream* __os, const ::RoboCompLaser::TData* begin, const ::RoboCompLaser::TData* end)
{
    ::Ice::Int size = static_cast< ::Ice::Int>(end - begin);
    __os->writeSize(size);
    for(int i = 0; i < size; ++i)
    {
        begin[i].__write(__os);
    }
}

void
RoboCompLaser::__readTLaserData(::IceInternal::BasicStream* __is, ::RoboCompLaser::TLaserData& v)
{
    ::Ice::Int sz;
    __is->readSize(sz);
    __is->checkFixedSeq(sz, 6);
    v.resize(sz);
    for(int i = 0; i < sz; ++i)
    {
        v[i].__read(__is);
    }
}

::RoboCompLaser::TLaserData
IceProxy::RoboCompLaser::Laser::getLaserData(const ::Ice::Context* __ctx)
{
    int __cnt = 0;
    while(true)
    {
        ::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase;
        try
        {
#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600) // C++Builder 2009 compiler bug
            IceUtil::DummyBCC dummy;
#endif
            __checkTwowayOnly(__RoboCompLaser__Laser__getLaserData_name);
            __delBase = __getDelegate(false);
            ::IceDelegate::RoboCompLaser::Laser* __del = dynamic_cast< ::IceDelegate::RoboCompLaser::Laser*>(__delBase.get());
            return __del->getLaserData(__ctx);
        }
        catch(const ::IceInternal::LocalExceptionWrapper& __ex)
        {
            __handleExceptionWrapper(__delBase, __ex, 0);
        }
        catch(const ::Ice::LocalException& __ex)
        {
            __handleException(__delBase, __ex, 0, __cnt);
        }
    }
}

::RoboCompLaser::LaserConfData
IceProxy::RoboCompLaser::Laser::getLaserConfData(const ::Ice::Context* __ctx)
{
    int __cnt = 0;
    while(true)
    {
        ::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase;
        try
        {
#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600) // C++Builder 2009 compiler bug
            IceUtil::DummyBCC dummy;
#endif
            __checkTwowayOnly(__RoboCompLaser__Laser__getLaserConfData_name);
            __delBase = __getDelegate(false);
            ::IceDelegate::RoboCompLaser::Laser* __del = dynamic_cast< ::IceDelegate::RoboCompLaser::Laser*>(__delBase.get());
            return __del->getLaserConfData(__ctx);
        }
        catch(const ::IceInternal::LocalExceptionWrapper& __ex)
        {
            __handleExceptionWrapper(__delBase, __ex, 0);
        }
        catch(const ::Ice::LocalException& __ex)
        {
            __handleException(__delBase, __ex, 0, __cnt);
        }
    }
}

const ::std::string&
IceProxy::RoboCompLaser::Laser::ice_staticId()
{
    return ::RoboCompLaser::Laser::ice_staticId();
}

::IceInternal::Handle< ::IceDelegateM::Ice::Object>
IceProxy::RoboCompLaser::Laser::__createDelegateM()
{
    return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM::RoboCompLaser::Laser);
}

::IceInternal::Handle< ::IceDelegateD::Ice::Object>
IceProxy::RoboCompLaser::Laser::__createDelegateD()
{
    return ::IceInternal::Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD::RoboCompLaser::Laser);
}

::IceProxy::Ice::Object*
IceProxy::RoboCompLaser::Laser::__newInstance() const
{
    return new Laser;
}

::RoboCompLaser::TLaserData
IceDelegateM::RoboCompLaser::Laser::getLaserData(const ::Ice::Context* __context)
{
    ::IceInternal::Outgoing __og(__handler.get(), __RoboCompLaser__Laser__getLaserData_name, ::Ice::Normal, __context);
    bool __ok = __og.invoke();
    ::RoboCompLaser::TLaserData __ret;
    try
    {
        if(!__ok)
        {
            try
            {
                __og.throwUserException();
            }
            catch(const ::Ice::UserException& __ex)
            {
                ::Ice::UnknownUserException __uue(__FILE__, __LINE__, __ex.ice_name());
                throw __uue;
            }
        }
        ::IceInternal::BasicStream* __is = __og.is();
        __is->startReadEncaps();
        ::RoboCompLaser::__readTLaserData(__is, __ret);
        __is->endReadEncaps();
        return __ret;
    }
    catch(const ::Ice::LocalException& __ex)
    {
        throw ::IceInternal::LocalExceptionWrapper(__ex, false);
    }
}

::RoboCompLaser::LaserConfData
IceDelegateM::RoboCompLaser::Laser::getLaserConfData(const ::Ice::Context* __context)
{
    ::IceInternal::Outgoing __og(__handler.get(), __RoboCompLaser__Laser__getLaserConfData_name, ::Ice::Normal, __context);
    bool __ok = __og.invoke();
    ::RoboCompLaser::LaserConfData __ret;
    try
    {
        if(!__ok)
        {
            try
            {
                __og.throwUserException();
            }
            catch(const ::Ice::UserException& __ex)
            {
                ::Ice::UnknownUserException __uue(__FILE__, __LINE__, __ex.ice_name());
                throw __uue;
            }
        }
        ::IceInternal::BasicStream* __is = __og.is();
        __is->startReadEncaps();
        __ret.__read(__is);
        __is->endReadEncaps();
        return __ret;
    }
    catch(const ::Ice::LocalException& __ex)
    {
        throw ::IceInternal::LocalExceptionWrapper(__ex, false);
    }
}

::RoboCompLaser::TLaserData
IceDelegateD::RoboCompLaser::Laser::getLaserData(const ::Ice::Context* __context)
{
    class _DirectI : public ::IceInternal::Direct
    {
    public:

        _DirectI(::RoboCompLaser::TLaserData& __result, const ::Ice::Current& __current) : 
            ::IceInternal::Direct(__current),
            _result(__result)
        {
        }
        
        virtual ::Ice::DispatchStatus
        run(::Ice::Object* object)
        {
            ::RoboCompLaser::Laser* servant = dynamic_cast< ::RoboCompLaser::Laser*>(object);
            if(!servant)
            {
                throw ::Ice::OperationNotExistException(__FILE__, __LINE__, _current.id, _current.facet, _current.operation);
            }
            _result = servant->getLaserData(_current);
            return ::Ice::DispatchOK;
        }
        
    private:
        
        ::RoboCompLaser::TLaserData& _result;
    };
    
    ::Ice::Current __current;
    __initCurrent(__current, __RoboCompLaser__Laser__getLaserData_name, ::Ice::Normal, __context);
    ::RoboCompLaser::TLaserData __result;
    try
    {
        _DirectI __direct(__result, __current);
        try
        {
            __direct.servant()->__collocDispatch(__direct);
        }
        catch(...)
        {
            __direct.destroy();
            throw;
        }
        __direct.destroy();
    }
    catch(const ::Ice::SystemException&)
    {
        throw;
    }
    catch(const ::IceInternal::LocalExceptionWrapper&)
    {
        throw;
    }
    catch(const ::std::exception& __ex)
    {
        ::IceInternal::LocalExceptionWrapper::throwWrapper(__ex);
    }
    catch(...)
    {
        throw ::IceInternal::LocalExceptionWrapper(::Ice::UnknownException(__FILE__, __LINE__, "unknown c++ exception"), false);
    }
    return __result;
}

::RoboCompLaser::LaserConfData
IceDelegateD::RoboCompLaser::Laser::getLaserConfData(const ::Ice::Context* __context)
{
    class _DirectI : public ::IceInternal::Direct
    {
    public:

        _DirectI(::RoboCompLaser::LaserConfData& __result, const ::Ice::Current& __current) : 
            ::IceInternal::Direct(__current),
            _result(__result)
        {
        }
        
        virtual ::Ice::DispatchStatus
        run(::Ice::Object* object)
        {
            ::RoboCompLaser::Laser* servant = dynamic_cast< ::RoboCompLaser::Laser*>(object);
            if(!servant)
            {
                throw ::Ice::OperationNotExistException(__FILE__, __LINE__, _current.id, _current.facet, _current.operation);
            }
            _result = servant->getLaserConfData(_current);
            return ::Ice::DispatchOK;
        }
        
    private:
        
        ::RoboCompLaser::LaserConfData& _result;
    };
    
    ::Ice::Current __current;
    __initCurrent(__current, __RoboCompLaser__Laser__getLaserConfData_name, ::Ice::Normal, __context);
    ::RoboCompLaser::LaserConfData __result;
    try
    {
        _DirectI __direct(__result, __current);
        try
        {
            __direct.servant()->__collocDispatch(__direct);
        }
        catch(...)
        {
            __direct.destroy();
            throw;
        }
        __direct.destroy();
    }
    catch(const ::Ice::SystemException&)
    {
        throw;
    }
    catch(const ::IceInternal::LocalExceptionWrapper&)
    {
        throw;
    }
    catch(const ::std::exception& __ex)
    {
        ::IceInternal::LocalExceptionWrapper::throwWrapper(__ex);
    }
    catch(...)
    {
        throw ::IceInternal::LocalExceptionWrapper(::Ice::UnknownException(__FILE__, __LINE__, "unknown c++ exception"), false);
    }
    return __result;
}

::Ice::ObjectPtr
RoboCompLaser::Laser::ice_clone() const
{
    throw ::Ice::CloneNotImplementedException(__FILE__, __LINE__);
    return 0; // to avoid a warning with some compilers
}

static const ::std::string __RoboCompLaser__Laser_ids[2] =
{
    "::Ice::Object",
    "::RoboCompLaser::Laser"
};

bool
RoboCompLaser::Laser::ice_isA(const ::std::string& _s, const ::Ice::Current&) const
{
    return ::std::binary_search(__RoboCompLaser__Laser_ids, __RoboCompLaser__Laser_ids + 2, _s);
}

::std::vector< ::std::string>
RoboCompLaser::Laser::ice_ids(const ::Ice::Current&) const
{
    return ::std::vector< ::std::string>(&__RoboCompLaser__Laser_ids[0], &__RoboCompLaser__Laser_ids[2]);
}

const ::std::string&
RoboCompLaser::Laser::ice_id(const ::Ice::Current&) const
{
    return __RoboCompLaser__Laser_ids[1];
}

const ::std::string&
RoboCompLaser::Laser::ice_staticId()
{
    return __RoboCompLaser__Laser_ids[1];
}

::Ice::DispatchStatus
RoboCompLaser::Laser::___getLaserData(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    __inS.is()->skipEmptyEncaps();
    ::IceInternal::BasicStream* __os = __inS.os();
    ::RoboCompLaser::TLaserData __ret = getLaserData(__current);
    if(__ret.size() == 0)
    {
        __os->writeSize(0);
    }
    else
    {
        ::RoboCompLaser::__writeTLaserData(__os, &__ret[0], &__ret[0] + __ret.size());
    }
    return ::Ice::DispatchOK;
}

::Ice::DispatchStatus
RoboCompLaser::Laser::___getLaserConfData(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    __inS.is()->skipEmptyEncaps();
    ::IceInternal::BasicStream* __os = __inS.os();
    ::RoboCompLaser::LaserConfData __ret = getLaserConfData(__current);
    __ret.__write(__os);
    return ::Ice::DispatchOK;
}

static ::std::string __RoboCompLaser__Laser_all[] =
{
    "getLaserConfData",
    "getLaserData",
    "ice_id",
    "ice_ids",
    "ice_isA",
    "ice_ping"
};

::Ice::DispatchStatus
RoboCompLaser::Laser::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)
{
    ::std::pair< ::std::string*, ::std::string*> r = ::std::equal_range(__RoboCompLaser__Laser_all, __RoboCompLaser__Laser_all + 6, current.operation);
    if(r.first == r.second)
    {
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
    }

    switch(r.first - __RoboCompLaser__Laser_all)
    {
        case 0:
        {
            return ___getLaserConfData(in, current);
        }
        case 1:
        {
            return ___getLaserData(in, current);
        }
        case 2:
        {
            return ___ice_id(in, current);
        }
        case 3:
        {
            return ___ice_ids(in, current);
        }
        case 4:
        {
            return ___ice_isA(in, current);
        }
        case 5:
        {
            return ___ice_ping(in, current);
        }
    }

    assert(false);
    throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}

void
RoboCompLaser::Laser::__write(::IceInternal::BasicStream* __os) const
{
    __os->writeTypeId(ice_staticId());
    __os->startWriteSlice();
    __os->endWriteSlice();
#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug
    Object::__write(__os);
#else
    ::Ice::Object::__write(__os);
#endif
}

void
RoboCompLaser::Laser::__read(::IceInternal::BasicStream* __is, bool __rid)
{
    if(__rid)
    {
        ::std::string myId;
        __is->readTypeId(myId);
    }
    __is->startReadSlice();
    __is->endReadSlice();
#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug
    Object::__read(__is, true);
#else
    ::Ice::Object::__read(__is, true);
#endif
}

void
RoboCompLaser::Laser::__write(const ::Ice::OutputStreamPtr&) const
{
    Ice::MarshalException ex(__FILE__, __LINE__);
    ex.reason = "type RoboCompLaser::Laser was not generated with stream support";
    throw ex;
}

void
RoboCompLaser::Laser::__read(const ::Ice::InputStreamPtr&, bool)
{
    Ice::MarshalException ex(__FILE__, __LINE__);
    ex.reason = "type RoboCompLaser::Laser was not generated with stream support";
    throw ex;
}

void 
RoboCompLaser::__patch__LaserPtr(void* __addr, ::Ice::ObjectPtr& v)
{
    ::RoboCompLaser::LaserPtr* p = static_cast< ::RoboCompLaser::LaserPtr*>(__addr);
    assert(p);
    *p = ::RoboCompLaser::LaserPtr::dynamicCast(v);
    if(v && !*p)
    {
        IceInternal::Ex::throwUOE(::RoboCompLaser::Laser::ice_staticId(), v->ice_id());
    }
}

bool
RoboCompLaser::operator==(const ::RoboCompLaser::Laser& l, const ::RoboCompLaser::Laser& r)
{
    return static_cast<const ::Ice::Object&>(l) == static_cast<const ::Ice::Object&>(r);
}

bool
RoboCompLaser::operator<(const ::RoboCompLaser::Laser& l, const ::RoboCompLaser::Laser& r)
{
    return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r);
}
